import { HttpClient } from '@angular/common/http';
import { Inject, Injectable } from '@angular/core';
import { API_CONFIG, ServiceModule } from './service.module';

@Injectable({
  providedIn: ServiceModule
})
export class CustomService {

  constructor(private http: HttpClient, @Inject(API_CONFIG) private uri: string) { }

  login(data: any) {
    let url = this.uri + '/custom/login';
    return this.http.post(url, data);
  }

  exists(userName: string) {
    let url = this.uri + '/custom/exists';
    return this.http.post(url, { userName: userName });
  }

  register(data: any) {
    let url = this.uri + '/custom/register';
    return this.http.post(url, data);
  }

  profile() {
    let url = this.uri + '/custom/profile';
    return this.http.get(url);
  }

  modify(data: any) {
    let url = this.uri + '/custom/modify';
    return this.http.put(url, data);
  }

  password(data: any) {
    let url = this.uri + '/custom/modify/password';
    return this.http.put(url, data);
  }

  resetPassword(data: any) {
    let url = this.uri + '/custom/reset/password';
    return this.http.put(url, data);
  }

  sendMail(email: string) {
    let url = this.uri + '/custom/send/email';
    return this.http.post(url, { email: email });
  }

  sendPhone(phone: string) {
    let url = this.uri + '/custom/send/phone';
    return this.http.post(url, { phone: phone });
  }

  sendAccount(userName: string) {
    let url = this.uri + '/custom/send/account';
    return this.http.post(url, { userName: userName });
  }

}
